﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace nhanvien
{
    class nhanvienDAL
    {
        public nhanvienDAL()
        {
        }
        public DataTable DocDanhSachNhanVien()
        {
            SqlConnection conn = SqlConnect.getConnect();
            conn.Open();
            SqlCommand cmd = new SqlCommand("select * from nhanvien ", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(dr);
            return dt;


        }
        public void ThemNhanVien(string manv, string tennv, string ngaysinh, string donvi)
        {
            SqlConnection conn = SqlConnect.getConnect();
            conn.Open();
            SqlCommand cmd = new SqlCommand("insert into NhanVien values(N'" + manv + "',N'" + tennv + "','" + ngaysinh + "',N'" + donvi + "')", conn);
            cmd.ExecuteNonQuery();
        }
        public void XoaNhanVien(string manv)
        {
            SqlConnection conn = SqlConnect.getConnect();
            conn.Open();
            SqlCommand cmd = new SqlCommand("delete from nhanvien where manv='" + manv + "'", conn);
            cmd.ExecuteNonQuery();

        }
        public void GhiNhanVien(string manv, string tennv, string ngaysinh, string donvi)
        {
            SqlConnection conn = SqlConnect.getConnect();
            conn.Open();
            SqlCommand cmd = new SqlCommand("update nhanvien set  manv=N'" + manv + "', tennv=N'" + tennv + "',ngaysinh='" + ngaysinh + "', donvi=N'" + donvi + "' where manv='" + manv + "'", conn);
            cmd.ExecuteNonQuery();
        }

    }

}
